home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-08-16 | 2.3 KB | 74 lines | [TEXT/MPS ] |
- #----------------------------------------------------------------------------------------------------------------------------------------------------
- # GoTo
- # MPW Shell Script
- # Written by Gina Cherry • August 16, 1991
- # Copyright: © 1991 by Apple Computer, Inc., all rights reserved.
- #
- # Usage:
- # GoTo [LineNumber] [Window]
- #
- # Function:
- # GoTo positions the cursor at the beginning of the specified line number in the specified window. If no line
- # number is specified, GoTo prompt the user for a line number. If no window is specified, GoTo
- # operates on the target window.
- #
- # Note: GoTo can be added to the Find menu with the following command:
- #
- # AddMenu Find 'GoTo/7' ∂
- # 'GoTo "{Active}"'
- #----------------------------------------------------------------------------------------------------------------------------------------------------
-
- # Make sure there are no more than 2 parameters.
- If {#} > 2
- Echo "### Usage: {0} [LineNumber] [Window]"
- Exit 1
- End >> Dev:StdErr
-
- # Don't exit on error.
- Set Exit 0
-
- # Initialize variables.
- Set Window ""
- Set LineNum ""
-
- # Loop through parameters.
- For Item in {"Parameters"}
-
- # If the parameter consists of numbers, it is the line number.
- If "{Item}" =~ /[0-9]+/
- If {LineNum} == ""
- Set LineNum "{Item}"
- Else
- Echo "### Line number multiply defined."
- Echo "### Usage: {0} [LineNumber] [Window]"
- Exit 1
- End
- # Otherwise, the parameter is the name of the window.
- Else
- If {Window} == ""
- Set Window "{Item}"
- Else
- Echo "### Window multiply defined."
- Echo "### Usage: {0} [LineNumber] [Window]"
- Exit 1
- End
- End >> Dev:StdErr
- End
-
- # If no window name was given on the command line, Window is the target window.
- If "{Window}" == ""
- Set Window "{Target}"
- End
-
- # Extract the leaf name of the window, and store in ®1.
- (Evaluate "{Window}" =~/:*([¬:]+:*)*([¬:]+)®1/) ∑ Dev:Null
-
-
- # If no line number was specified, prompt the user for a line number.
- If "{LineNum}" == ""
- Set LineNum `Request "Go to what line in {®1}?" || Exit 0` > Dev:Null
- End
-
- # Position cursor at the beginning of line number LineNum in the window Window.
- # Note: If Window is not a valid window, Find will write an error message to standard error.
- Find Δ"{LineNum}" "{Window}"